using System;
using System.Collections.Generic;
using System.Text;

using Forms = Microsoft.Vbe.Interop.Forms;
using Outlook = Microsoft.Office.Interop.Outlook;
using System.Drawing;
using System.IO;
using System.Runtime.InteropServices.ComTypes;
using System.Globalization;

namespace Microsoft.SoftwarePlusServices.ReferenceBits.OutlookPlusServices.Regions
{
    /// <summary>
    /// Represents the code behind for  form region IssueTrackerFolderView used to display items.
    /// </summary>
    internal class IssueTrackerFolderView : IItemRegion
    {
        #region IItemRegion Fields
        private string _guid;
        private Microsoft.Office.Interop.Outlook.PostItem _item;
        Outlook.FormRegion _formRegion;
        private EventHandler _close;
        #endregion

        #region Private Fields
        #endregion

        #region Constructor
        /// <summary>
        /// Initializes an instance of the <see cref="ItemRegionBase"/> class 
        /// and initiates the connection between IssueTrackerFolderView and the code behind.
        /// </summary>
        /// <param name="outlookItem">The current outlook item displayed in the form region.</param>
        /// <param name="region">A reference to the interface of the form region.  
        /// Used to gain direct access to the controls on the form region.
        /// </param>
        public IssueTrackerFolderView(string guid)
        {
            _guid = guid;
        }

        /// <summary>
        /// Customize is called by the FormRegionManager once the item region is associated 
        /// with a specific form
        /// </summary>
        public void Customize(Microsoft.Office.Interop.Outlook.FormRegion formRegion, object outlookItem)
        {
            _formRegion = formRegion;
            _item = (Outlook.PostItem)outlookItem;

            // connect to the region form
            Forms.UserForm m_userForm = _formRegion.Form as Forms.UserForm;

            _formRegion.Close += new Outlook.FormRegionEvents_CloseEventHandler(ItemRegionClose);

        }

        /// <summary>
        /// When the item region closes we must call back to the form region
        /// to perform additional cleanup
        /// </summary>
        void ItemRegionClose()
        {
            if (_close != null)
                _close(this, EventArgs.Empty);
        }
        #endregion



        #region IItemRegion Properties
        public string GUID
        {
            get { return (_guid); }
            set { _guid = value; }
        }

        public Microsoft.Office.Interop.Outlook.PostItem Item
        {
            get { return (_item); }
            set { _item = value; }
        }

        public EventHandler Close
        {
            get { return (_close); }
            set { _close = value; }
        }
        #endregion

    
        ////////////////////////////////
        // Put your custom methods here
        ////////////////////////////////

        #region Custom Properties
		// TODO Add any custom properties to IssueTrackerFolderView
        #endregion


        #region Custom Methods
		// TODO Add custom logica to IssueTrackerFolderView
        #endregion

        #region Event Handler Methods
		// TODO If IssueTrackerFolderView has any controls, add event handlers
        #endregion

    }
}
